//
// Description: 5958. 股票平滑下跌阶段的数目
// Created by Loading on 2021/12/19.
//

#include <bits/stdc++.h>

using namespace std;

long long getDescentPeriods(vector<int> &prices) {
    int n = prices.size();
    long long res = n;
    // 连续次数
    int c = 1;
    for (int i = 1; i < n; ++i) {
        if (prices[i] == prices[i - 1] - 1) {
            res += c;
            c++;
        } else {
            c = 1;
        }
    }

    return res;
}

int main() {
    vector<int> prices = {3, 2, 1, 4};
    long long res = getDescentPeriods(prices);
    cout << res << endl;

    return 0;
}
